﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using MakeIT.MiraPark.Negocios;
using Microsoft.Reporting.WinForms;

namespace MiraPark{

    public partial class FormReportRecibo : Form
    {
        public FormReportRecibo()
        {
            InitializeComponent();
        }

        private void FormTesteRelatorio_Load(object sender, EventArgs e)
        {
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        public void setDataSource(List<EmpresaVO> listEmpresaVOs, string pagador, string recebedor, string doc, string numdoc, decimal valor, string valorExt, string cidade, string referente)
        {
            this.numericUpDownValor.Value = valor;
            this.textBoxNrDoc.Text = numdoc;
            this.textBoxPagante.Text = pagador;
            this.textBoxRecebedor.Text = recebedor;
            this.textBoxTipoDoc.Text = doc;
            this.textBoxRef.Text = referente;

            this.BindingSource.DataSource = listEmpresaVOs;

        }

        private void buttonVisualizar_Click(object sender, EventArgs e)
        {
            NumeroPorExtenso npe = new NumeroPorExtenso(this.numericUpDownValor.Value);
            EmpresaVO empresaVO = ModelBO.getEmpresa(int.Parse(ModelBO.getParametro("Empresa Ativa")));

            List<ReportParameter> rps = new List<ReportParameter>();
            rps.Add(new ReportParameter("Empresa", empresaVO.nome));
            rps.Add(new ReportParameter("Pagador", this.textBoxPagante.Text));
            rps.Add(new ReportParameter("Recebedor", this.textBoxRecebedor.Text));
            rps.Add(new ReportParameter("Doc", (this.textBoxTipoDoc.Text.Length==0?"NOTPRINT":this.textBoxTipoDoc.Text)));
            rps.Add(new ReportParameter("NumDoc", this.textBoxNrDoc.Text));
            rps.Add(new ReportParameter("Valor", this.numericUpDownValor.Value.ToString()));
            rps.Add(new ReportParameter("ValorExt", npe.ToString()));
            rps.Add(new ReportParameter("Cidade", empresaVO.cidade));
            rps.Add(new ReportParameter("Referente", this.textBoxRef.Text));

            this.reportViewer1.LocalReport.SetParameters(rps);
            this.reportViewer1.RefreshReport();
        }

   }
}
